package ivo.service.impl;

import java.io.InputStream;
import java.util.List;
import java.util.Properties;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import ivo.dao.IWfmDao;
import ivo.dao.IWfmPptDao;
import ivo.pojo.AcarristPO;
import ivo.pojo.AeqptPO;
import ivo.pojo.AeqptptPO;
import ivo.pojo.AeqptstPO;
import ivo.pojo.DcarrixfPO;
import ivo.pojo.RetBoxPO;
import ivo.pojo.StockerPO;
import ivo.service.IWfmService;

@Component("wfmService")
public class WfmService implements IWfmService {

	private IWfmDao wfmDao;
	private IWfmPptDao wfmPptDao;
	private List<AeqptstPO> eqStatList;
	private List<AeqptstPO> eqStatOkQty;
	private List<AeqptstPO>toolTactTime;
	@Override
	public List<RetBoxPO> selectCrrInfo(String crrID){
		return wfmPptDao.selectCrrInfo(crrID);
	}
	//获取储位中卡匣信息
	public List<AcarristPO> selectBoxId(String shelfID){
		return wfmPptDao.selectBoxId(shelfID);
	}
	@Override
	public String selectEqptBay(String fr_eqpt_id,String to_eqpt_id){
		return wfmPptDao.rtnLoadCrrUseTime(fr_eqpt_id,to_eqpt_id);
	}

	public List<AeqptstPO> getEqStatOkQty() {
		return eqStatOkQty;
	}
	public void setEqStatOkQty(List<AeqptstPO> eqStatOkQty) {
		this.eqStatOkQty = eqStatOkQty;
	}
	@Override
	public List<AeqptstPO> selectEqStat() {

		// TODO Auto-generated method stub
		List<AeqptstPO> eqptList = wfmDao.selectEqStat();
		return eqptList;
	}

	@Override
	public List<AcarristPO> selectTransfter(String eqptID) {
		// TODO Auto-generated method stub
		return wfmDao.selectTransfter(eqptID);
	}
	
    @Override
	public List<AcarristPO> selectMainOperCrrCnt(String to_eqpt_id){
		return wfmPptDao.selectMainOperCrrCnt(to_eqpt_id);
	}
    
    @Override
    public List<AcarristPO> selectDcarristStkCrrList(String stk_id){
    	return wfmPptDao.selectDcarristStkCrrList(stk_id);
    }
    
    /*获取stk的状态
     * (non-Javadoc)
     * @see ivo.service.IWfmService#selectStockerstat(java.lang.String)*/
     
    public List<StockerPO> selectStockerstat(String stk_id){
    	return wfmPptDao.selectStockerstat(stk_id);
    }
    
    public List<AeqptstPO> getToolTactTime() {
		return toolTactTime;
	}
	public void setToolTactTime(List<AeqptstPO> toolTactTime) {
		this.toolTactTime = toolTactTime;
	}
	@Override
    public String getStkLayout(String stk_id){
    	String layout = "";
    	Properties prop =  new  Properties(); 
    	try{
    		InputStream in =  WfmService.class.getResourceAsStream("/in_STK_Distribution.properties");
    		prop.load(in);
    		layout =String.valueOf(prop.getProperty (stk_id));
    	}catch (Exception e){
    		
    	}
    	return layout;
    }
    
    @Override
    public String getPortInfor(String stk_id){
    	String portInfor = "";
    	Properties prop = new Properties();
    	try{
    		InputStream in = WfmService.class.getResourceAsStream("/stkPortInfor.properties");
    		prop.load(in);
    		portInfor=String.valueOf(prop.getProperty (stk_id));
    	}catch(Exception e){
    		
    	}
    	return portInfor;
    }

//	@Override
//	public List<AcarristPO> selcetInprCrrCount() {
//		// TODO Auto-generated method stub
//		return wfmDao.selcetInprCrrCount();
//	}
//
//	@Override
//	public List<AcarristPO> selectWaitCrrCount() {
//		// TODO Auto-generated method stub
//		return wfmDao.selectWaitCrrCount();
//	}

	@Override
	public List<AeqptptPO> selectPtStat() {
		// TODO Auto-generated method stub
		return wfmDao.selectPtStat();
	}
	
	public IWfmDao getWfmDao() {
		return wfmDao;
	}

	@Resource
	public void setWfmDao(IWfmDao wfmDao) {
		this.wfmDao = wfmDao;
	}

	public IWfmPptDao getWfmPptDao() {
		return wfmPptDao;
	}

	@Resource
	public void setWfmPptDao(IWfmPptDao wfmPptDao) {
		this.wfmPptDao = wfmPptDao;
	}
	
	/*public List<AeqptstPO> selectEqStatKT() {
		// TODO Auto-generated method stub
		eqStatList=wfmDao.selectEqStatKT();
		eqStatOkQty=wfmDao.selectEqQty();
		toolTactTime=wfmDao.selectTactTime();
		for(AeqptstPO aeqptstpo:eqStatList){
			int time=Integer.parseInt(aeqptstpo.getKeepTime());
			aeqptstpo.setKtime(time);
		}
		return eqStatList;
	}*/
	public List<AeqptstPO> getEqStatList() {
		return eqStatList;
	}
	public void setEqStatList(List<AeqptstPO> eqStatList) {
		this.eqStatList = eqStatList;
	}
	/*public List<DcarrixfPO> getUsrnameInfo() {
		// TODO Auto-generated method stub
		return wfmPptDao.getUsrnameInfo();
	}*/
	
//	//新增一个方法对port口状态信息获取
//	public AeqptstPO selectEqptSt(String eqpt_id){
//		return wfmPptDao.selectEqptSt(eqpt_id);
//	}
	
	//新增的获取机台布局信息的方法和机台上面卡匣列表的方法
//	public String getEqptLayout(String eqpt_id) {
//		String layout = "";
//    	Properties prop =  new  Properties(); 
//    	try{
//    		//这里需要一个机台分配文件in_EQPT_Distrubution.properties来替换以下文件
//    		InputStream in =  WfmService.class.getResourceAsStream("/in_STK_Distribution.properties");
//    		prop.load(in);
//    		layout =String.valueOf(prop.getProperty (eqpt_id));
//    	}catch (Exception e){
//    		
//    	}
//    	return layout;
//	}
//	public List<AcarristPO> selectDcarristEqptCrrList(String eqpt_id) {
//		
//		return wfmPptDao.selectDcarristEqptCrrList(eqpt_id);
//	}
}
